home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: nsmart@indigo.ie (Niall Smart)
- Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
- Subject: Re: C coding problem
- Date: 3 Apr 1996 07:15:38 -0600
- Organization: None
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4jttlq$3p1@solutions.solon.com>
- References: <4ianbf$h86@solutions.solon.com> <4iemcl$a05@solutions.solon.com> <4io1io$no4@solutions.solon.com> <4j41ru$nq4@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- Michael Smith <msmith@mpx.com.au> wrote:
-
- >Konrad Schwarz wrote:
- >>
- >> I recently wrote a loop that went like this:
- >>
- >> while (p < end_p)
- >> ++*p++;
- >>
-
- >This is largely a matter of taste
-
- I would argue that it is far more than that.
-
- >, but personally I don't like that
- >construct. A programmer less skilled than you might easily misunderstand
- >that and introduce an error. I would prefer:
-
- >for ( ; p<end_p; p++)
- > ++(*p);
-
- or either of:
-
- while (p < end_p)
- {
- (*p)++;
- p++;
- }
-
- while (p++ < end_p)
- {
- (*p)++;
- }
-
- Zero chance for ambiguity in the last three versions.
-
- Niall
-